home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 0411.ZIP / STRNGHEX.C < prev    next >
Text File  |  1985-07-22  |  584b  |  29 lines

  1. /*
  2.  * Program to read the keyboard and return the hex and decimal equivalents.
  3.  */
  4. #include "stdio.h"
  5. main()
  6.     {
  7.     int  c,
  8.      incntr,
  9.      outcntr,
  10.      finished;
  11.     short instring[256];
  12.     finished = 0;
  13.     while (!finished)
  14.     {
  15.     puts("\nType in a string terminated by [Enter] to see its hex values\n");
  16.     incntr = 0;
  17.     while ((instring[incntr++] = getchar()) != 0xd);
  18.     printf("\n");
  19.     outcntr = 0;
  20.     if (!(finished = (incntr == 1)))
  21.         {
  22.         while (outcntr < (incntr-1))
  23.         printf("%x ",instring[outcntr++]);
  24.         printf("\n");
  25.         }
  26.     }
  27.     exit(0);
  28.     }
  29.